package ru.inse.web.page;

import ru.inse.web.layout.InseLayoutFactory;
import ru.xeden.web.html.module.IModule;
import ru.xeden.web.html.page.IPage;
import ru.xeden.web.html.page.IPageFactory;
import ru.xeden.web.html.page.PageImpl;

public class InsePageFactory
    implements IPageFactory
{
    private PageImpl indexPage;
    private PageImpl adminPage;
    
    @Override
    public IPage createPage(String url, IModule module)
    {
        if ("admin".equals(url))
        {
            if (adminPage == null)
            {
                adminPage = new PageImpl();
                adminPage.setRootNode(module.createLayout(InseLayoutFactory.ADMIN_LAYOUT_ID, module));
            }
            return adminPage;
        }
        else if (indexPage == null)
        {
            indexPage = new PageImpl();
            indexPage.setRootNode(module.createLayout(InseLayoutFactory.INDEX_LAYOUT_ID, module));
        }
        return indexPage;
    }

}
